package com.raa.core;

import java.util.HashMap;
import java.util.LinkedList;

public class RaA {

	public static final String GLOBAL_RAA_NAME = "Global RaA";

	public static final HashMap<String, RaA> instances;

	static {
		instances = new HashMap<>();
	}

	public static RaABuilder builder() {
		return new RaABuilder();
	}

	public static RaA global() {
		return instances.get(GLOBAL_RAA_NAME);
	}

	private String name;
	private LinkedList<Role> roles;

	protected RaA(String name, LinkedList<Role> roles) {
		this.name = name;
		this.roles = roles;
	}

	public Role role(String name) {
		for (Role role : roles) {
			if (role.getName().equals(name))
				return role;
		}
		throw new NullPointerException("找不到角色: [" + name + "]");
	}

}
